//
//  QJTypeTJVC.m
//  QuanJieShopProject
//
//  Created by 刘中义 on 2018/3/1.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "QJTypeTJVC.h"

@interface QJTypeTJVC ()

@end

@implementation QJTypeTJVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"我的推荐人";
    [self dataRequestAction];
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //控件不被导航栏遮挡
    self.navigationController.navigationBar.translucent = NO;
}
- (void)dataRequestAction{
    
    [WWNetRequest fetchMyReferralWithParameters:nil success:^(id response) {
        if ([response isKindOfClass:[NSDictionary class]]) {
            
            NSDictionary *dict = response[@"data"];
            [_userImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",NET_BASEURL_IMG,dict[@"head_pic"]]] placeholderImage:KImageName(@"noImage")];
            _userNumber.text = [NSString stringWithFormat:@"%@",dict[@"mobile"]];
            _userNickname.text = [NSString stringWithFormat:@"%@",dict[@"nickname"]];
            _userPhone.text = [NSString stringWithFormat:@"%@",dict[@"mobile"]];
            NSString *sex = [NSString stringWithFormat:@"%@",dict[@"sex"]];
            if ([sex isEqualToString:@"1"]) {
                _userSex.text = @"男";
            }else if ([sex isEqualToString:@"2"]){
                _userSex.text = @"女";
            }else{
                _userSex.text = @"保密";
            }
            NSString *str = [NSString stringWithFormat:@"%@",dict[@"user_type"]];
            //user_type =1  是 泉界会员，2 是泉界创客，3，是泉界商家
            if ([str isEqualToString:@"1"]) {
                _userType.text = @"泉界会员";
            }else if ([str isEqualToString:@"2"]){
                _userType.text = @"泉界创客";
            }else if ([str isEqualToString:@"3"]){
                _userType.text = @"泉界商家";
            }
        }
        
    } failure:^(NSDictionary *error) {
        
        if ([error isKindOfClass:[NSDictionary class]]) {
            if ([[error objectForKey:@"msg"]isEqualToString:@"我没有推荐人!"]) {
                for (int i = 100; i<104; i++) {
                   UIView *view =  [self.view viewWithTag:i];
                    [view removeFromSuperview];
                }
               
              
                
            }
        }
    }];

}

@end
